package main

import (
	"github.com/joho/godotenv"
	"os"
)

/*******************************************************************/
// Setting
/*******************************************************************/

type Setting struct {
	Server           ServerConfig
	Debug            string //是否开启debug模式
	KEY              string //JWT加密key
	DefaultOllamaUrl string //LLM访问地址
	KnowledgeBaseDir string //知识库目录路径
	LLMModel         string //大数据模型
	LLMAgentNotice   string //助手提示

}

var MyConfig *Setting

type ServerConfig struct {
	Host string
	Port string
}

func assertEnv(key string) string {
	value := os.Getenv(key)
	if value == "" {
		panic("Environment variable " + key + " is not set")
	}
	return value
}

func init() {
	env := os.Getenv("GIN_ENV")
	_ = godotenv.Load()
	_ = godotenv.Load(".env.local")  // Load example if .env is not found
	_ = godotenv.Load(".env." + env) // Load environment-specific config

	MyConfig = &Setting{
		Server: ServerConfig{
			Host: assertEnv("HOST"),
			Port: assertEnv("PORT"),
		},
		DefaultOllamaUrl: assertEnv("DEFAULT_OLLAMA_URL"),
		KnowledgeBaseDir: assertEnv("KNOWLEDGE_BASE_DIR"),
		LLMModel:         assertEnv("LLM_MODEL"),
		LLMAgentNotice:   assertEnv("LLM_AGENT_NOTICE"),
	}
}
